﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PaydSystem.Cls;
using Oracle.DataAccess.Client;
using PaydSystem.Common;
using System.Data;

namespace PaydSystem.DataAccess
{
    public class PaydUserDa
    {
        FunctionCommon Confn = new FunctionCommon();

        public List<PaydUserCls> GetListDataDa(string sorting = "")
        {

            using (OracleConnection conn = new OracleConnection(DefaultValue.strConnectString))
            {
                conn.Open();

                List<PaydUserCls> ListData = new List<PaydUserCls>();
                OracleCommand cmd = new OracleCommand();
                OracleParameter p_refcursor = new OracleParameter();
                try
                {


                    cmd = conn.CreateCommand();

                    cmd.CommandText = "PAYD_GET_USER";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add("P_MEMBER_ID", OracleDbType.Varchar2, 8).Value = "";
                    cmd.Parameters.Add("P_ID_CARD", OracleDbType.Varchar2, 20).Value = "";
                    cmd.Parameters.Add("P_USER_ID", OracleDbType.Varchar2, 20).Value = "";
                    cmd.Parameters.Add("P_EMAIL_PRIMARY", OracleDbType.Varchar2, 100).Value = "";
                    cmd.Parameters.Add("P_SORT", OracleDbType.Varchar2, 100).Value = sorting;
                    cmd.Parameters.Add("P_ERROR", OracleDbType.Int32, 4000).Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("P_RESULT", OracleDbType.Int32, 10).Direction = ParameterDirection.Output;

                    p_refcursor.ParameterName = "P_CURSOR";
                    p_refcursor.OracleDbType = OracleDbType.RefCursor;
                    p_refcursor.Direction = ParameterDirection.Output;
                    cmd.Parameters.Add(p_refcursor);
                    cmd.ExecuteNonQuery();

                    DataTable dt = new DataTable();
                    OracleDataAdapter a = new OracleDataAdapter(cmd);
                    DataSet ds = new DataSet();

                    a.Fill(ds);

                    var objresult = cmd.Parameters["P_RESULT"].Value.ToString().Trim();
                    var objerror = cmd.Parameters["P_ERROR"].Value.ToString().Trim();

                    var result = Convert.ToInt32(objresult);

                    dt = ds.Tables[0];
                    if (result == 1 && dt.Rows.Count > 0)
                    {

                        foreach (DataRow dr in dt.Rows)
                        {
                            PaydUserCls RecData = new PaydUserCls();
                            RecData = SetObj(dr);
                            ListData.Add(RecData);
                        }

                        return ListData;
                    }
                    else if (result == 0)
                    {
                        Confn.Logger("Error at GetListDataDa procedure PAYD_GET_USER " + objerror);
                    }
                    return ListData;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);

                    Confn.Logger("Error at GetListDataDa procedure PAYD_GET_USER " + ex.Message.ToString() + " " + ex.StackTrace.ToString());

                    throw ex;
                }
                finally
                {
                    cmd.Parameters.Clear();

                    p_refcursor.Dispose();
                    cmd.Dispose();
                    conn.Close();
                    conn.Dispose();
                }
            }
        }

        public PaydUserCls GetRecDataDa(string memberId, string idCard,string userId, string emailPrimary)
        {

            using (OracleConnection conn = new OracleConnection(DefaultValue.strConnectString))
            {
                conn.Open();

                PaydUserCls RecData = new PaydUserCls();
                OracleCommand cmd = new OracleCommand();
                OracleParameter p_refcursor = new OracleParameter();
                try
                {


                    cmd = conn.CreateCommand();
                    cmd.CommandText = "PAYD_GET_USER";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add("P_MEMBER_ID", OracleDbType.Varchar2, 8).Value = memberId.Trim();
                    cmd.Parameters.Add("P_ID_CARD", OracleDbType.Varchar2, 20).Value = idCard.Trim();
                    cmd.Parameters.Add("P_USER_ID", OracleDbType.Varchar2, 20).Value = userId.Trim();
                    cmd.Parameters.Add("P_EMAIL_PRIMARY", OracleDbType.Varchar2, 100).Value = emailPrimary.Trim();
                    cmd.Parameters.Add("P_SORT", OracleDbType.Varchar2, 100).Value = "";
                    cmd.Parameters.Add("P_ERROR", OracleDbType.Int32, 4000).Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("P_RESULT", OracleDbType.Int32, 10).Direction = ParameterDirection.Output;
                    //cmd.Parameters.Add("P_CURSOR", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
                    p_refcursor.ParameterName = "P_CURSOR";
                    p_refcursor.OracleDbType = OracleDbType.RefCursor;
                    p_refcursor.Direction = ParameterDirection.Output;
                    cmd.Parameters.Add(p_refcursor);
                    cmd.ExecuteNonQuery();

                    DataTable dt = new DataTable();
                    OracleDataAdapter a = new OracleDataAdapter(cmd);
                    DataSet ds = new DataSet();

                    a.Fill(ds);
                    var objresult = cmd.Parameters["P_RESULT"].Value.ToString().Trim();
                    var objerror = cmd.Parameters["P_ERROR"].Value.ToString().Trim();
                    var result = Convert.ToInt32(objresult);
                    dt = ds.Tables[0];
                    if (result == 1 && dt.Rows.Count > 0)
                    {

                        DataRow dr = dt.Rows[0];
                        RecData = SetObj(dr);

                        return RecData;
                    }
                    else if (result == 0)
                    {
                        Confn.Logger("Error at GetRecDataDa procedure PAYD_GET_USER " + objerror);
                    }
                    return RecData;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);

                    Confn.Logger("Error at GetRecDataDa procedure PAYD_GET_USER " + ex.Message.ToString() + " " + ex.StackTrace.ToString());

                    throw ex;
                }
                finally
                {
                    cmd.Parameters.Clear();

                    p_refcursor.Dispose();
                    cmd.Dispose();
                    conn.Close();
                    conn.Dispose();
                }
            }
        }

        public int SavePaydUserDa(PaydUserCls paydUserObj)
        {
            using (OracleConnection conn = new OracleConnection(DefaultValue.strConnectString))
            {
                conn.Open();
                int tranResult = 1;
                var tranError = "";
                OracleTransaction transaction = conn.BeginTransaction();
                OracleCommand cmd = new OracleCommand();
                try
                {
                    cmd = conn.CreateCommand();
                    cmd.Transaction = transaction;
                    cmd.CommandText = "PAYD_SAVE_USER";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add("P_MEMBER_ID", OracleDbType.Varchar2, 8).Value = paydUserObj.MemberId.ToString().Trim();
                    cmd.Parameters.Add("P_EMAIL_PRIMARY", OracleDbType.Varchar2, 100).Value = paydUserObj.EmailPrimary.Trim();
                    cmd.Parameters.Add("P_EMAIL_SECODNARY", OracleDbType.Varchar2, 100).Value = paydUserObj.EmailSecondary.Trim();
                    cmd.Parameters.Add("P_MOBILE_NO", OracleDbType.Varchar2, 50).Value = paydUserObj.MobileNo.Trim();
                    cmd.Parameters.Add("P_PASSWORD_USER", OracleDbType.Varchar2, 4000).Value = paydUserObj.PasswordUser.Trim();
                    cmd.Parameters.Add("P_SECURITY_KEY", OracleDbType.Varchar2, 20).Value = DefaultValue.strSecurityKey.Trim();
                    cmd.Parameters.Add("P_ERROR", OracleDbType.Varchar2, 4000).Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("P_RESULT", OracleDbType.Int32, 10).Direction = ParameterDirection.Output;
                    cmd.ExecuteNonQuery();
                    tranResult = Convert.ToInt32(cmd.Parameters["P_RESULT"].Value.ToString());
                    tranError = cmd.Parameters["P_ERROR"].Value.ToString();
                    if (tranResult == 0)
                    {
                        transaction.Rollback();
                        Confn.Logger("Error at SavePaydUserDa procedure PAYD_SAVE_USER " + tranError);
                        return tranResult;
                    }
                    else if (tranResult != 1)
                    {
                        transaction.Rollback();
                        return tranResult;
                    }
                    transaction.Commit();
                    return tranResult;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    transaction.Rollback();
                    Confn.Logger("Error at SavePaydUserDa procedure PAYD_SAVE_USER " + ex.Message.ToString() + " " + ex.StackTrace.ToString());
                    throw;
                }
                finally
                {
                    cmd.Parameters.Clear();
                    cmd.Dispose();
                    conn.Close();
                    conn.Dispose();
                }
            }
        }

        public int PaydCheckUserDa(string idCard)
        {
            using (OracleConnection conn = new OracleConnection(DefaultValue.strConnectString))
            {
                conn.Open();
                OracleCommand cmd = new OracleCommand();
                var result = "";
                var resultData = 0;
                try
                {
                    cmd = conn.CreateCommand();
                    cmd.CommandText = "PAYD_CHECK_USER";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add("P_ID_CARD", OracleDbType.Varchar2, 20).Value = idCard.Trim();
                    cmd.Parameters.Add("P_ERROR", OracleDbType.Int32, 4000).Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("P_RESULT", OracleDbType.Int32, 10).Direction = ParameterDirection.Output;
                    cmd.ExecuteNonQuery();
                    result = cmd.Parameters["P_RESULT"].Value.ToString().Trim();
                    resultData = Convert.ToInt32(result);
                    return resultData;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    Confn.Logger("function PaydCheckUserDa procedure PAYD_CHECK_USER " + ex.Message.ToString() + " " + ex.StackTrace.ToString());
                    throw ex;
                }
                finally
                {
                    cmd.Parameters.Clear();
                    cmd.Dispose();
                    conn.Close();
                    conn.Dispose();
                }
            }
        }

        public int ActivateUserDa(string memberId)
        {
            using (OracleConnection conn = new OracleConnection(DefaultValue.strConnectString))
            {
                conn.Open();
                int tranResult = 1;
                var tranError = "";
                OracleTransaction transaction = conn.BeginTransaction();
                OracleCommand cmd = new OracleCommand();
                try
                {
                    cmd = conn.CreateCommand();
                    cmd.Transaction = transaction;
                    cmd.CommandText = "PAYD_ACTIVATE_USER";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add("P_MEMBER_ID", OracleDbType.Varchar2, 8).Value = memberId.Trim();
                    cmd.Parameters.Add("P_ERROR", OracleDbType.Varchar2, 4000).Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("P_RESULT", OracleDbType.Int32, 10).Direction = ParameterDirection.Output;
                    cmd.ExecuteNonQuery();
                    tranResult = Convert.ToInt32(cmd.Parameters["P_RESULT"].Value.ToString());
                    tranError = cmd.Parameters["P_ERROR"].Value.ToString();
                    if (tranResult == 0)
                    {
                        transaction.Rollback();
                        Confn.Logger("Error at ActivateUserDa procedure PAYD_ATIVATE_USER " + tranError);
                        return tranResult;
                    }
                    else if (tranResult != 1)
                    {
                        transaction.Rollback();
                        return tranResult;
                    }
                    transaction.Commit();
                    return tranResult;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    transaction.Rollback();
                    Confn.Logger("Error at ActivateUserDa procedure PAYD_ATIVATE_USER " + ex.Message.ToString() + " " + ex.StackTrace.ToString());
                    throw;
                }
                finally
                {
                    cmd.Parameters.Clear();
                    cmd.Dispose();
                    conn.Close();
                    conn.Dispose();
                }
            }
        }

        public int CheckUserLoginDa(string username, string password)
        {
            using (OracleConnection conn = new OracleConnection(DefaultValue.strConnectString))
            {
                conn.Open();

                OracleCommand cmd = new OracleCommand();
                var result = "";
                var resultData = 0;
                try
                {


                    cmd = conn.CreateCommand();
                    cmd.CommandText = "PAYD_CHECK_USER_LOGIN";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add("P_USERNAME", OracleDbType.Varchar2, 100).Value = username.Trim();
                    cmd.Parameters.Add("P_PASSWORD", OracleDbType.Varchar2, 20).Value = password.Trim();
                    cmd.Parameters.Add("P_SECURITY_KEY", OracleDbType.Varchar2, 20).Value = DefaultValue.strSecurityKey.Trim();
                    cmd.Parameters.Add("P_RESULT", OracleDbType.Int32, 10).Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();


                    result = cmd.Parameters["P_RESULT"].Value.ToString().Trim();
                    resultData = Convert.ToInt32(result);

                    return resultData;

                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);

                    Confn.Logger("function CheckUserLoginDa procedure PAYD_CHECK_USER_LOGIN " + ex.Message.ToString() + " " + ex.StackTrace.ToString());

                    throw;
                }
                finally
                {

                    cmd.Parameters.Clear();

                    cmd.Dispose();
                    conn.Close();
                    conn.Dispose();
                }
            }
        }

        public int SendForgetPwdDa(string email)
        {
            using (OracleConnection conn = new OracleConnection(DefaultValue.strConnectString))
            {
                conn.Open();
                int tranResult = 1;
                var tranError = "";
                OracleTransaction transaction = conn.BeginTransaction();
                OracleCommand cmd = new OracleCommand();
                try
                {
                    cmd = conn.CreateCommand();
                    cmd.Transaction = transaction;
                    cmd.CommandText = "PAYD_SEND_FORGET_PWD";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add("P_EMAIL", OracleDbType.Varchar2, 100).Value = email.Trim();
                    cmd.Parameters.Add("P_ERROR", OracleDbType.Varchar2, 4000).Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("P_RESULT", OracleDbType.Int32, 10).Direction = ParameterDirection.Output;
                    cmd.ExecuteNonQuery();
                    tranResult = Convert.ToInt32(cmd.Parameters["P_RESULT"].Value.ToString());
                    tranError = cmd.Parameters["P_ERROR"].Value.ToString();
                    if (tranResult == 0)
                    {
                        transaction.Rollback();
                        Confn.Logger("Error at SendForgetPwdDa procedure PAYD_SEND_FORGET_PWD " + tranError);
                        return tranResult;
                    }
                    else if (tranResult != 1)
                    {
                        transaction.Rollback();
                        return tranResult;
                    }
                    transaction.Commit();
                    return tranResult;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    transaction.Rollback();
                    Confn.Logger("Error at SendForgetPwdDa procedure PAYD_SEND_FORGET_PWD " + ex.Message.ToString() + " " + ex.StackTrace.ToString());
                    throw;
                }
                finally
                {
                    cmd.Parameters.Clear();
                    cmd.Dispose();
                    conn.Close();
                    conn.Dispose();
                }
            }
        }

        public int SavePwdForForgetDa(string memberId,string password)
        {
            using (OracleConnection conn = new OracleConnection(DefaultValue.strConnectString))
            {
                conn.Open();
                int tranResult = 1;
                var tranError = "";
                OracleTransaction transaction = conn.BeginTransaction();
                OracleCommand cmd = new OracleCommand();
                try
                {
                    cmd = conn.CreateCommand();
                    cmd.Transaction = transaction;
                    cmd.CommandText = "PAYD_SAVE_PWD_FOR_FORGET";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add("P_MEMBER_ID", OracleDbType.Varchar2, 8).Value = memberId.Trim();
                    cmd.Parameters.Add("P_PASSWORD", OracleDbType.Varchar2, 20).Value = password.Trim();
                    cmd.Parameters.Add("P_SECURITY_KEY", OracleDbType.Varchar2, 20).Value = DefaultValue.strSecurityKey.Trim();
                    cmd.Parameters.Add("P_ERROR", OracleDbType.Varchar2, 4000).Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("P_RESULT", OracleDbType.Int32, 10).Direction = ParameterDirection.Output;
                    cmd.ExecuteNonQuery();
                    tranResult = Convert.ToInt32(cmd.Parameters["P_RESULT"].Value.ToString());
                    tranError = cmd.Parameters["P_ERROR"].Value.ToString();
                    if (tranResult == 0)
                    {
                        transaction.Rollback();
                        Confn.Logger("Error at SavePwdForForgetDa procedure PAYD_SAVE_PWD_FOR_FORGET " + tranError);
                        return tranResult;
                    }
                    else if (tranResult != 1)
                    {
                        transaction.Rollback();
                        return tranResult;
                    }
                    transaction.Commit();
                    return tranResult;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    transaction.Rollback();
                    Confn.Logger("Error at SavePwdForForgetDa procedure PAYD_SAVE_PWD_FOR_FORGET " + ex.Message.ToString() + " " + ex.StackTrace.ToString());
                    throw;
                }
                finally
                {
                    cmd.Parameters.Clear();
                    cmd.Dispose();
                    conn.Close();
                    conn.Dispose();
                }
            }
        }

        

        public int ChkExpireChangePwdDa(string memberId)
        {
            using (OracleConnection conn = new OracleConnection(DefaultValue.strConnectString))
            {
                conn.Open();

                OracleCommand cmd = new OracleCommand();
                var result = "";
                var resultData = 0;
                try
                {


                    cmd = conn.CreateCommand();
                    cmd.CommandText = "PAYD_CHECK_EXPIRE_CHANGE_PWD";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Clear();
                    cmd.Parameters.Add("P_MEMBER_ID", OracleDbType.Varchar2, 8).Value = memberId.Trim();
                    cmd.Parameters.Add("P_ERROR", OracleDbType.Varchar2, 4000).Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("P_RESULT", OracleDbType.Int32, 10).Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();


                    result = cmd.Parameters["P_RESULT"].Value.ToString().Trim();
                    resultData = Convert.ToInt32(result);

                    return resultData;

                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);

                    Confn.Logger("function ChkExpireChangePwdDa procedure PAYD_CHECK_EXPIRE_CHANGE_PWD " + ex.Message.ToString() + " " + ex.StackTrace.ToString());

                    throw;
                }
                finally
                {

                    cmd.Parameters.Clear();

                    cmd.Dispose();
                    conn.Close();
                    conn.Dispose();
                }
            }
        }

        public PaydUserCls SetObj(DataRow dr)
        {
            PaydUserCls objData = new PaydUserCls();
            try
            {
                objData.MemberId = Convert.ToInt32(dr["MEMBER_ID"]);
                objData.IdCard = dr["ID_CARD"].ToString().Trim();
                objData.UserId = dr["USER_ID"].ToString().Trim();
                objData.Title = dr["TITLE"].ToString().Trim();
                objData.Name = dr["NAME"].ToString().Trim();
                objData.Addr1 = dr["ADDR1"].ToString().Trim();
                objData.Addr2 = dr["ADDR2"].ToString().Trim();
                objData.ZipCode = dr["ZIP_CODE"].ToString().Trim();
                objData.EmailPrimary = dr["EMAIL_PRIMARY"].ToString().Trim();
                objData.EmailSecondary = dr["EMAIL_SECONDARY"].ToString().Trim();
                objData.MobileNo = dr["MOBILE_NO"].ToString().Trim();
                objData.PasswordUser = "";
                objData.PasswordAioiUser = "";
                objData.Flag = dr["FLAG"].ToString().Trim();
                objData.Status = dr["STATUS"].ToString().Trim();
                objData.RegisterFlag = dr["REGISTER_FLAG"].ToString().Trim();
                if (dr["CREATE_BY"] != DBNull.Value)
                {
                    objData.CreateBy = Convert.ToInt32(dr["CREATE_BY"]);
                    PaydUserCls objDataCreateBy = new PaydUserCls();
                    objDataCreateBy.IdCard = dr["CREATE_BY_ID_CARD"].ToString().Trim();
                    objDataCreateBy.UserId = dr["CREATE_BY_USER_ID"].ToString().Trim();
                    objDataCreateBy.Title = dr["CREATE_BY_TITLE"].ToString().Trim();
                    objDataCreateBy.Name = dr["CREATE_BY_NAME"].ToString().Trim();
                    objDataCreateBy.Addr1 = dr["CREATE_BY_ADDR1"].ToString().Trim();
                    objDataCreateBy.Addr2 = dr["CREATE_BY_ADDR2"].ToString().Trim();
                    objDataCreateBy.ZipCode = dr["CREATE_BY_ZIP_CODE"].ToString().Trim();
                    objDataCreateBy.EmailPrimary = dr["CREATE_BY_EMAIL_PRIMARY"].ToString().Trim();
                    objDataCreateBy.EmailSecondary = dr["CREATE_BY_EMAIL_SECONDARY"].ToString().Trim();
                    objDataCreateBy.MobileNo = dr["CREATE_BY_MOBILE_NO"].ToString().Trim();
                    objDataCreateBy.PasswordUser = "";
                    objDataCreateBy.PasswordAioiUser = "";
                    objDataCreateBy.Flag = dr["CREATE_BY_FLAG"].ToString().Trim();
                    objDataCreateBy.Status = dr["CREATE_BY_STATUS"].ToString().Trim();
                    objDataCreateBy.RegisterFlag = dr["CREATE_BY_REGISTER_FLAG"].ToString().Trim();
                    
                    objData.CreateByObj = objDataCreateBy;
                }
                if (dr["MODIFY_BY"] != DBNull.Value)
                {
                    objData.ModifyBy = Convert.ToInt32(dr["MODIFY_BY"]);
                    PaydUserCls objDataModifyBy = new PaydUserCls();
                    objDataModifyBy.IdCard = dr["MODIFY_BY_ID_CARD"].ToString().Trim();
                    objDataModifyBy.UserId = dr["MODIFY_BY_USER_ID"].ToString().Trim();
                    objDataModifyBy.Title = dr["MODIFY_BY_TITLE"].ToString().Trim();
                    objDataModifyBy.Name = dr["MODIFY_BY_NAME"].ToString().Trim();
                    objDataModifyBy.Addr1 = dr["MODIFY_BY_ADDR1"].ToString().Trim();
                    objDataModifyBy.Addr2 = dr["MODIFY_BY_ADDR2"].ToString().Trim();
                    objDataModifyBy.ZipCode = dr["MODIFY_BY_ZIP_CODE"].ToString().Trim();
                    objDataModifyBy.EmailPrimary = dr["MODIFY_BY_EMAIL_PRIMARY"].ToString().Trim();
                    objDataModifyBy.EmailSecondary = dr["MODIFY_BY_EMAIL_SECONDARY"].ToString().Trim();
                    objDataModifyBy.MobileNo = dr["MODIFY_BY_MOBILE_NO"].ToString().Trim();
                    objDataModifyBy.PasswordUser = "";
                    objDataModifyBy.PasswordAioiUser = "";
                    objDataModifyBy.Flag = dr["MODIFY_BY_FLAG"].ToString().Trim();
                    objDataModifyBy.Status = dr["MODIFY_BY_STATUS"].ToString().Trim();
                    objDataModifyBy.RegisterFlag = dr["MODIFY_BY_REGISTER_FLAG"].ToString().Trim();
                    
                    objData.ModifyByObj = objDataModifyBy;
                }
                
                if (dr["CREATE_DATE"] != DBNull.Value)
                {
                    objData.CreateDate = Convert.ToDateTime(dr["CREATE_DATE"].ToString());

                }
                if (dr["MODIFY_DATE"] != DBNull.Value)
                {
                    objData.ModifyDate = Convert.ToDateTime(dr["MODIFY_DATE"].ToString());

                }
                if (dr["IMPORT_DATE"] != DBNull.Value)
                {
                    objData.ImportDate = Convert.ToDateTime(dr["IMPORT_DATE"].ToString());

                }
                if (dr["ACTIVATE_DATE"] != DBNull.Value)
                {
                    objData.ActivateDate = Convert.ToDateTime(dr["ACTIVATE_DATE"].ToString());

                }
                if (dr["FORGET_PWD_DATE"] != DBNull.Value)
                {
                    objData.ForgetPwdDate = Convert.ToDateTime(dr["FORGET_PWD_DATE"].ToString());

                }
                return objData;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);

                Confn.Logger("Error at SetObj PaydUserCls " + ex.Message.ToString() + " " + ex.StackTrace.ToString());

                throw ex;
            }
        }
    }
}